Vue.js
Material Design 谷歌推出了全新的设计语言Material Design。谷歌表示,这种设计语言旨在为手机、平板电脑、台式机和“其他平台”提供更一致、更广泛的“外观和感觉”。(网上copy的)
<!-- 引用 materialize 的样式 -->
<link href="http://cdn.bootcss.com/materialize/0.97.6/css/materialize.min.css" rel="stylesheet">
// directive
Vue.directive('effect', {
bind: function() {
var el = this.el
el.classList.add('waves-effect')
this.expression && el.classList.add('waves-' + this.expression)
function convertStyle(obj) {
var style = '';
for (var a in obj) {
if (obj.hasOwnProperty(a)) {
style += (a + ':' + obj[a] + ';');
}
}
return style;
}
this.handler = function(e) {
var ripple = document.createElement('div');
ripple.classList.add('waves-ripple');
el.appendChild(ripple);
var styles = {
'left': e.layerX + 'px',
'top': e.layerY + 'px',
'opacity': 1,
'transform': 'scale(' + ((el.clientWidth / 100) * 10) + ')',
'transition-duration': '750ms',
'transition-timing-function': 'cubic-bezier(0.250, 0.460, 0.450, 0.940)'
};
ripple.setAttribute('style', convertStyle(styles));
setTimeout(function() {
ripple.setAttribute('style', convertStyle({
'opacity': 0,
'transform': styles.transform,
'left': styles.left,
'top': styles.top
}));
setTimeout(function() {
ripple && el.removeChild(ripple);
}, 750);
//
}, 450);
}
this.el.addEventListener('mousedown', this.handler, false)
},
unbind: function() {
this.el.removeEventListener('mousedown', this.handler)
}
})
使用
<div id="app">
<div class="container" style="padding:20px 0">
<p>
<button type="button" class="btn btn-large" v-effect="light"> Button effect - light</button>
</p>
<p>
<button type="button" class="btn btn-large" v-effect="red"> Button effect - red </button>
</p>
<p>
<button type="button" class="btn btn-large" v-effect="yellow"> Button effect - yellow</button>
</p>
<p>
<button type="button" class="btn btn-large" v-effect="orange"> Button effect - orange</button>
</p>
<p>
<button type="button" class="btn btn-large" v-effect="purple"> Button effect - purple</button>
</p>
<p>
<button type="button" class="btn btn-large" v-effect="green"> Button effect - green</button>
</p>
<p>
<button type="button" class="btn btn-large" v-effect="teal"> Button effect - teal</button>
</p>
</div>
</div>
<script>
new Vue({
el: '#app'
});
</script>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。